package models

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
)

var DB = Init()

func Init() *gorm.DB {
	dsn := "mis_nbdz_com_cn:5CazcK4ifWKCaZTB@tcp(43.142.187.20:3306)/mis_nbdz_com_cn?charset=utf8mb4&parseTime=True"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) //打开数据库
	if err != nil {
		log.Println("调用成功失败", err)
	} else {
		fmt.Println("调用成功！")
	}
	return db
}
func AutoMigrate() (err error) {
	//创建数据表
	err = DB.AutoMigrate(&MAdminUserB{})
	if err != nil {
		return err
	}
	return nil
}
